import React from "react";
import { connect } from "react-redux";
import { Modal } from "antd";

const ModalButton = ({ modalReactMicro }) => {
  const showModal = () => {
    React.$setGlobalState({ modalReactMicro: true });
  };

  const handleOk = () => {
    React.$setGlobalState({ modalReactMicro: false });
  };

  const handleCancel = () => {
    React.$setGlobalState({ modalReactMicro: false });
  };
  return (
    <>
      <span onClick={showModal}>打开reactMicro的对话框</span>
      <Modal
        title="Basic Modal"
        visible={modalReactMicro}
        onOk={handleOk}
        onCancel={handleCancel}
      >
        <p>Some contents...</p>
        <p>Some contents...</p>
        <p>Some contents...</p>
      </Modal>
    </>
  );
};

export default connect((state) => ({
  modalReactMicro: state.global.modalReactMicro,
}))(ModalButton);
